package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RptIdv;
import com.ruoyi.system.service.IRptIdvService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存每日快照Controller
 * 
 * @author ruoyi
 * @date 2025-06-18
 */
@Controller
@RequestMapping("/system/idv")
public class RptIdvController extends BaseController
{
    private String prefix = "system/idv";

    @Autowired
    private IRptIdvService rptIdvService;

    @RequiresPermissions("system:idv:view")
    @GetMapping()
    public String idv()
    {
        return prefix + "/idv";
    }

    /**
     * 查询库存每日快照列表
     */
    @RequiresPermissions("system:idv:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RptIdv rptIdv)
    {
        startPage();
        List<RptIdv> list = rptIdvService.selectRptIdvList(rptIdv);
        return getDataTable(list);
    }

    /**
     * 导出库存每日快照列表
     */
    @RequiresPermissions("system:idv:export")
    @Log(title = "库存每日快照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RptIdv rptIdv)
    {
        List<RptIdv> list = rptIdvService.selectRptIdvList(rptIdv);
        ExcelUtil<RptIdv> util = new ExcelUtil<RptIdv>(RptIdv.class);
        return util.exportExcel(list, "库存每日快照数据");
    }

    /**
     * 新增库存每日快照
     */
    @RequiresPermissions("system:idv:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存库存每日快照
     */
    @RequiresPermissions("system:idv:add")
    @Log(title = "库存每日快照", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RptIdv rptIdv)
    {
        return toAjax(rptIdvService.insertRptIdv(rptIdv));
    }

    /**
     * 修改库存每日快照
     */
    @RequiresPermissions("system:idv:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        RptIdv rptIdv = rptIdvService.selectRptIdvById(id);
        mmap.put("rptIdv", rptIdv);
        return prefix + "/edit";
    }

    /**
     * 修改保存库存每日快照
     */
    @RequiresPermissions("system:idv:edit")
    @Log(title = "库存每日快照", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RptIdv rptIdv)
    {
        return toAjax(rptIdvService.updateRptIdv(rptIdv));
    }

    /**
     * 删除库存每日快照
     */
    @RequiresPermissions("system:idv:remove")
    @Log(title = "库存每日快照", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(rptIdvService.deleteRptIdvByIds(ids));
    }
}
